package edu.spec.student.dao.impl;

import edu.spec.student.dao.iface.IStudentQuestionnaireDao;
import edu.spec.student.model.questionnaire.StudentQuestionnaire;
import org.madgecko.basic.dao.BaseDao;
import org.springframework.stereotype.Repository;

/**
 * Author       : MadFrog
 * Date         : 2018/2/18 23:00
 * Description  :
 */
@Repository
public class StudentQuestionnaireDao extends BaseDao<StudentQuestionnaire> implements IStudentQuestionnaireDao{

    @Override
    public StudentQuestionnaire load(Integer sId, Integer qId) {
        String hql = "from StudentQuestionnaire sq where sq.student.id=" + sId + " and sq.questionnaire.id=" + qId;
        return (StudentQuestionnaire)this.queryObject(hql);
    }

    @Override
    public void deleteByQuestionnaire(Integer questionnaireId) {
        String hql = "delete from StudentQuestionnaire sq where sq.questionnaire.id=" + questionnaireId;
        this.updateByHql(hql);
    }

}
